package br.unip.tcc.domotic.controller;
import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.hibernate.FetchMode;
import org.hibernate.criterion.Criterion;

import br.unip.tcc.domotic.bean.AbstractBean;
import br.unip.tcc.domotic.exception.FilterException;
import br.unip.tcc.domotic.model.AbstractModel;

@SuppressWarnings("rawtypes")
public interface Controller<B extends AbstractBean, M extends AbstractModel> extends Serializable {
	
	public void insert();
	public void update();
	public String updateAction();
	
	public void delete();
	public void deleteAction();
	public void deleteById(Integer id);
	
	/* Users methods */
	public List<B> searchAll();
	public List<B> searchByFilter();
	
	/* Background methods */
	public List<B> searchByExample(B bean);
	//public B searchById(Integer id);
	public List<B> searchByCriteria(Criterion[] criterions);
	public List<B> getAll();
	
	
	public abstract Map<String, FetchMode> getDefaultJoins();
	public abstract Map<String, String> getDeafautOrdersBy();
	/* Users methods */
	public List<B> findAll();
	public List<B> findByFilter();
	/* Background methods */
	public List<B> findByExample(B bean, Map<String, FetchMode> joins, Map<String, String> orderBys);
	public B findById(String idField, Integer idValue, Map<String, FetchMode> joins, Map<String, String> orderBys);
	public List<B> findByCriteria(Criterion[] criterions, Map<String, FetchMode> joins, Map<String, String> orderBys);
	
	
	
	/* Validate filter */
	public void validateFilterSearch() throws FilterException;
	
	
	
	
	public B getBeanInstance();
	public M getModelInstance();
	public Class<M> getModelClass();
	public Class<B> getBeanClass();
	
	public abstract void setBeanId(Integer id);
	public abstract Integer extractBeanId(AbstractBean bean);
	public abstract String getBeanIdName();
	public abstract String getUpdateRedirectPage();
	public String getBeanIdField();
	
}
